//用于判断用户是否已经登陆了；
var userId = localStorage.getItem("userId");

function aa(){
	localStorage.setItem("userId","");
	getState();
}
//用于判断的登陆状态
	function getState(){
		console.log(localStorage.getItem("userId"))
		if(localStorage.getItem("userId")){
			
			$(".hideBox .loginaBox").hide();
			$(".hideBox .inforBox").show();
			$.ajax({
					type:"POST",
					url:ptms.url.common.mySelf.mySelf,
					data:{
						userId:userId,
					},
					success:function(data){
						
						var html = "";
						html += '<li><a href="html/myTrain.html">我的学习</a></li>' + 
									'<li><a href="#">' + data.data.znname + '</a></li>' + 
									'<li class="quit" onclick="aa()">退出</li>'
							
						$(".informationB").html(html);
						
						
					}
					
				})
			
		}else{
			
			$(".hideBox .loginaBox").show();
			$(".hideBox .inforBox").hide();
		}
	}
	getState();

//$.ajax({
//	type:"GET",
//	url:ptms.url.common.limitControl.isRegister,
//	success:function(date){
//		console.log(date);
//		if(data.code == 0){
//			//表示用户已经登陆状态
//			$(".loginaBox").hide();
//			$(".inforBox").show();
//			$.ajax({
//				type:"POST",
//				url:ptms.url.common.mySelf.mySelf,
//				success:function(data){
//					var html = "";
//					html += '<li><a href="../html/myTrain.html">我的学习</a></li>' + 
//								'<li><a href="#">王子 </a></li>' + 
//								'<li class="quit">退出</li>'
//					$(".informationB").html(html);
//					//点击按钮退出登陆
//					$(".quit").click(function(){
//						$.ajax({
//							type:"GET",
//							url:ptms.url.common.limitControl.loginOut,
//						})
//						
//					})
//				}
//			})
//		}else{
//			//表示用户尚未登陆;
//			$(".loginaBox").show();
//			$(".inforBox").hide();
//		}
//	},
//	async:true
//});


// 热门课程的操作
   $.ajax({
     type: "GET",
     url: ptms.url.common.courseManger.courseList + "?subjectId=1&offset=1&limit=6&couresesType=8",
	 success: function(data){
     	var html = "";
     	$.each(data,function(i,o){
     		html += '<div class="col-md-4 classItem"  aa="bb" data-id="' + o.id + '">' +
				'<div class="bgDiv clearfix">' + 
					'<div class="classImg">' + 
						'<img src="' + ptms.address2 + o.coursesCoverUrl + '" class="img-responsive"/>' + 
						'<div class="classImgText">' +
							'<span>查看课程</span>' + 
						'</div>' + 
					'</div>' + 
//					'<img src="' + ptms.url +  o.coursesPhotoUrl + '" class="classImg"/> ' + 
					'<div class="classAboutInformation pull-left">' + 
						'<span class="peopleNum">课程人数</span>' + 
						'<span class="num">' + o.userCount + '</span>'+
						'<span class="classTeacher">课程讲师</span>' + 
						'<span class="teacherName">' + o.professorName.split("，")[0] + '</span> ' + 
					'</div>' + 
				'</div>' + 
				'<div class="textBox">' + 
					'<p class="classItemTitle">' + o.coursesChnName + '</p>' +
					'<p class="state">免费</p>'  +
				'</div>' + 
			'</div>'
     	})
     	$("#index .hotClassBox").html(html);
     	$("#index .hotClassBox .classItem").click(function(){
	     	var id = $(this).data("id");
	     	window.location.href = "html/classBriefFree.html?courseId=" + id;
	     })
     	
      }
    })
   
//设计学的课程展示列表
$.ajax({
     type: "GET",
     url: ptms.url.common.courseManger.courseList + "?subjectId=2&offset=1&limit=6&couresesType=8",
	 success: function(data){
     	var html = "";
     	$.each(data,function(i,o){
     		html += '<div class="col-md-4 classItem"  aa="bb" data-id="' + o.id + '">' +
				'<div class="bgDiv clearfix">' + 
					'<div class="classImg">' + 
						'<img src="' + ptms.address2 + o.coursesCoverUrl + '" class="img-responsive"/>' + 
						'<div class="classImgText">' +
							'<span>查看课程</span>' + 
						'</div>' + 
					'</div>' + 
//					'<img src="' + ptms.url +  o.coursesPhotoUrl + '" class="classImg"/> ' + 
					'<div class="classAboutInformation pull-left">' + 
						'<span class="peopleNum">课程人数</span>' + 
						'<span class="num">' + o.userCount + '</span>'+
						'<span class="classTeacher">课程讲师</span>' + 
						'<span class="teacherName">' + o.professorName.split("，")[0] + '</span> ' + 
					'</div>' + 
				'</div>' + 
				'<div class="textBox">' + 
					'<p class="classItemTitle">' + o.coursesChnName + '</p>' +
					'<p class="state">免费</p>'  +
				'</div>' + 
			'</div>'
     	})
     	$("#index .artClassBox").html(html);
     	$("#index .artClassBox .classItem").click(function(){
     		var id = $(this).data("id");
	     	window.location.href = "html/classBriefFree.html?courseId=" + id;	
	    })
     	
      }
     
	})

//计算机科学与技术的模块数据
$.ajax({
     type: "GET",
     url: ptms.url.common.courseManger.courseList+ "?subjectId=3&offset=1&limit=6&couresesType=8",
	 success: function(data){
     	var html = "";
     	$.each(data,function(i,o){
     		html += '<div class="col-md-4 classItem"  aa="bb" data-id="' + o.id + '">' +
				'<div class="bgDiv clearfix">' + 
					'<div class="classImg">' + 
						'<img src="' + ptms.address2 + o.coursesCoverUrl + '" class="img-responsive"/>' + 
						'<div class="classImgText">' +
							'<span>查看课程</span>' + 
						'</div>' + 
					'</div>' + 
//					'<img src="' + ptms.url +  o.coursesPhotoUrl + '" class="classImg"/> ' + 
					'<div class="classAboutInformation pull-left">' + 
						'<span class="peopleNum">课程人数</span>' + 
						'<span class="num">' + o.userCount + '</span>'+
						'<span class="classTeacher">课程讲师</span>' + 
						'<span class="teacherName">' + o.professorName.split("，")[0] + '</span> ' + 
					'</div>' + 
				'</div>' + 
				'<div class="textBox">' + 
					'<p class="classItemTitle">' + o.coursesChnName + '</p>' +
					'<p class="state">免费</p>'  +
				'</div>' + 
			'</div>'
     	})
     	$("#index .computerArt").html(html);
     	
     	$("#index .computerArt .classItem").click(function(){
     		var id = $(this).data("id");
	     	window.location.href = "html/classBriefFree.html?courseId=" + id;
	    })
     	
      }
     
	})



//项目展示的列表
var offset = 0;
$.ajax({
	type:"POST",
	url:ptms.url.common.projectManger.projectList,
	data:{
		offset:offset,
		limit:2
	},
	success:function(data){
		var html = "";
		$.each(data.rows,function(i,o){
			html += '<div class="schoolAndSubjectItem">' + 
					'<div class="borderDiv">' + 
						'<div class="schoolBox">' + 
							'<div class="schoolItem clearfix">' + 
								'<div class="schoolInformation pull-left">' + 
									'<div class="schoolClassTitle">' + 
										'<p class="schoolClassName">' + o.projectName +'</p>' + 
										'<p class="schoolClassState">院校课程</p>' + 
									'</div>' + 
									'<div class="schoolClassBrief">' + o.projectIntro + '</div>' + 
								'</div>' + 
								'<div class="imgBox pull-left">' + 
									'<img src="' + o.projectPictureUrl + '"/>' + 
									'<div class="inforNum pull-left" id="aaa">' + 
										'<p class="fontColor">参与人数</p>' + 
										'<p class="claNum">' + o.planPeopleNumber + '</p>' + 
										'<p class="inforNuma fontColor">项目地址</p>' + 
										'<p class="classTeacher">' + o.regionName + '</p>' + 
									'</div>' + 
								'</div>' + 
							'</div>' + 
						'</div>' + 
					'</div>' + 
					'<div class="clearfix"></div>' + 
					'<div class="bgDi"></div>' + 
				'</div>'
		})
		$(".schoolAndSubjectList").html(html);	
	}
})

   
   
//大师的列表的操作
$.ajax({
	type:"GET",
	url:ptms.url.common.other.exportList,
	data:"",
	success:function(data){
		var html = "";
		$.each(data,function(i,o){
			html += '<div class="col-md-3 exportA">' + 
						'<div class="imgBox">' + 
							'<img src="' + o.photoUrlLarge + '" />' + 
						'</div>' + 
						'<div class="textBox">' + 
							'<p class="position">德稻可发展战略大师</p>' + 
							'<p class="name">' + o.znname + '</p>' + 
						'</div>' + 
					'</div>' 
		})
		$("#index .exportItem ").html(html);
	}
})
 

